<?php
namespace Home\Controller;
use Bqmart\Controller;
class RegionController extends CommController {
    //获取一级区域
    public function one_region(){
		$Model = M('region');
		$data =$Model->where('parent_id = 1')->select();
		if($data){
			echo (json_encode(array('code'=>0,'msg'=>'','data'=>$data)));	
		}else{
			echo (json_encode(array('code'=>1,'msg'=>'查询超时','data'=>'')));
		}
	   
    }
	//获取二级区域
    public function two_region(){
		
		if($_REQUEST['parent_id']){
			
			$parent_id = $_REQUEST['parent_id'];
			$Model = M('region');
			$data =$Model->where('parent_id = '.$parent_id.' ')->select();
			if($data){
				echo (json_encode(array('code'=>0,'msg'=>'','data'=>$data)));	
			}else{
				echo (json_encode(array('code'=>1,'msg'=>'查询超时','data'=>'')));
			}
	    }
    }
	
	//
}